//
// Created by gyc on 2021/1/7.
//

#include "../../common.h"

class Solution {
public:
    int removeDuplicates(vector<int>& nums) {
        if (nums.size() == 1) {
            return 1;
        }
        int fast = 1, slow = 1, target = nums[0];
        while (fast < nums.size()) {
            if (target != nums[fast]) {
                nums[slow] = nums[fast];
                ++slow;
                target = nums[fast];
            }
            ++fast;
        }
        return slow;
    }
};

int main() {
    vector<int> v{1,1,1,2,4,5,8};
    cout << Solution().removeDuplicates(v);
}